@extends('layouts.admin')

@section('css')

@endsection

@section('content')
    <section class="content" id="app">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-body">
                        <table class="table">
                            <tbody>
                                <tr>
                                    <td>任务状态</td>
                                    <td>{{$states[$details['state']]}}</td>
                                </tr>
                                <tr>
                                    <td>创建时间</td>
                                    <td>{{$details['created_at']}}</td>
                                </tr>
                                <tr>
                                    <td>发布时间</td>
                                    <td>{{$details['release_time']}}</td>
                                </tr>
                                <tr>
                                    <td>截止时间</td>
                                    <td>{{$details['deadlime']}}</td>
                                </tr>
                                <tr>
                                    <td>审核时长</td>
                                    <td>{{$details['hours']}}</td>
                                </tr>
                                <tr>
                                    <td>发布数量</td>
                                    <td>{{$details['number']}}</td>
                                </tr>
                                <tr>
                                    <td>已领数量</td>
                                    <td>{{$details['used_nums']}}</td>
                                </tr>
                                <tr>
                                    <td>任务说明</td>
                                    <td>
                                        {!! $details['task_desc'] !!}
                                    </td>
                                </tr>
                                <tr>
                                    <td>任务图例</td>
                                    <td>
                                        @foreach($details['images_arr'] as $k => $v)
                                            <img style="width: 50px;height: 50px" src="{{$v}}" alt="{{$v}}">
                                        @endforeach
                                    </td>
                                </tr>
                                <tr>
                                    <td>参数说明</td>
                                    <td>
                                        {!! $details['step_desc'] !!}
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <button class="btn btn-success" v-on:click="verify(3)">批准该任务</button>
                                        <button class="btn btn-danger" v-on:click="verify(2)">否决该任务</button>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </section>
@endsection

@section('script')
    <script type="text/javascript">

        require(['Vue', 'VueResource'], function (Vue, VueResource) {
            Vue.use(VueResource)
            var app = new Vue({
                el: '#app',
                data: {
                },
                methods : {
                    verify : function(state){
                        verifyTask(state);
                    }
                }
            })
            // 审批任务
            function verifyTask(state) {
                var data = {
                    state : state
                }
                app.$http.post("/admin/task/verify/{{$details['id']}}", data , {headers : header()})
                        .then(function(response){
                            var json = response.body;
                            alert(json.msg);
                            if(json.state == 1) {
                                window.location.reload();
                            }
                        }).catch(function(response){
                            console.log(response)
                        })
            }
        })

    </script>
@endsection